package org.example.myleet.p713;

public class Solution {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        if (k == 0) {
            return 0;
        }
        int count = 0, l = 0, n = nums.length, product = 1;
        for (int r = 0; r < n; ++r) {
            product *= nums[r];
            while (product >= k && l <= r) {
                product /= nums[l];
                ++l;
            }
            count += r - l + 1;
        }
        return count;
    }
}
